/*
 * @(#)XfsimKeyListener.java        1.0 2000/05/09
 *
 * This file is part of Xfuzzy 3.0, a design environment for fuzzy logic
 * based systems.
 *
 * (c) 2000 IMSE-CNM. The authors may be contacted by the email address:
 *                    xfuzzy-team@imse.cnm.es
 *
 * Xfuzzy is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 *
 * Xfuzzy is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */

package xfuzzy.xfsim.view.listener;

import java.awt.event.*;
import xfuzzy.xfsim.view.*;


/**
 * Controlador de eventos de teclado de la interfaz gr�fica de Xfsim
 * 
 * @author Francisco Jos� Moreno Velo
 *
 */
public class XfsimKeyListener implements KeyListener {

	//----------------------------------------------------------------------------//
	//                            MIEMBROS PRIVADOS                               //
	//----------------------------------------------------------------------------//

	/**
	 * Ventana
	 */
	private Xfsim xfsim;
	
	//----------------------------------------------------------------------------//
	//                                CONSTRUCTOR                                 //
	//----------------------------------------------------------------------------//

	/**
	 * Constructor
	 */
	public XfsimKeyListener(Xfsim xfsim) {
		this.xfsim = xfsim;		
	}

	//----------------------------------------------------------------------------//
	//                             M�TODOS P�BLICOS                               //
	//----------------------------------------------------------------------------//

	/**
	 * Interfaz KeyListener. Acci�n al soltar una tecla
	 */
	public void keyReleased(KeyEvent e) {
		int code = e.getKeyCode();
		if(code == KeyEvent.VK_BACK_SPACE) xfsim.removeOutput();
		if(code == KeyEvent.VK_DELETE) xfsim.removeOutput();
		if(code == KeyEvent.VK_CUT) xfsim.removeOutput();
		if(code == KeyEvent.VK_INSERT) xfsim.insertOutput();
		if(code == KeyEvent.VK_ENTER) xfsim.editOutput(); 
		if(code == 226) xfsim.editOutput(); 
		e.consume();
	}
	
	/**
	 * Interfaz KeyListener. Acci�n al apretar una tecla
	 */
	public void keyPressed(KeyEvent e) {	
	}

	/**
	 * Interfaz KeyListener. Acci�n al teclear.
	 */
	public void keyTyped(KeyEvent e) { 
	}
	
}
